//test

#include <bits/stdc++.h>
using namespace std;

class Solution {
private:
  vector<string> ans;
  vector<string> oneIp;
  void dfsIp(string s,int start) {
      if(oneIp.size()==4) {
          if (s.length() == start){
              string tmp = oneIp[0];
              for (int i=1; i<4; i++){
                  tmp += ("." + oneIp[i]);
              }
              ans.push_back(tmp);
          }
          return ;
      }
      if (s.length() <= start) {
          return ;
      }
      for(int len=1; len<4; len++){
          if(len>1 && s[start] == '0'){
              return ;
          }
          string segm = s.substr(start, len);
          if(len==3 && atoi(segm.c_str())>255) {
              return ;
          }
          oneIp.push_back(segm);
          dfsIp(s, start+len);
          oneIp.pop_back();
      }
  }
public:
  vector<string> restoreIpAddresses(string s) {
    dfsIp(s,0);
    return ans;
  }
};

int main_ip2() {
    vector<string> ret = Solution().restoreIpAddresses("25525511135");
    for (auto vt: ret) {
        printf("%s\n", vt.c_str());
    }
    cout << "end" << endl;
    return 0;
}
